# Recipe file for sdcv.
#
# Maintainers: (C) 2016 Mateus P. Rodrigues, mprodrigues@dragora.org.
#
# Under the terms of the GNU General Public License.

program=sdcv
version=0.5.0-beta2
release=1

description="
sdcv - console version of StarDict
"

homepage=https://dushistov.github.io/sdcv/
license=GPLv2

tarname=${program}-${version}-Source.tar.bz2
pkgname=${program}
pkgversion=0.5.0b2

# Remote source(s)
fetch=http://nbtelecom.dl.sourceforge.net/project/sdcv/sdcv/$tarname

# Parallel jobs for the compiler
jobs=3

# Source documentation
docs="AUTHORS LICENSE NEWS README.org"
docsdir="${docdir}/${program}-${version}"

build() {
    unpack "${tardir}/$tarname"

    cd "$srcdir"-Source

    mkdir -p build && cd build
    CMAKE_ROOT=/usr/share/cmake-2.8 cmake ..
    make -j${jobs}
    make -j${jobs} lang
    make -j${jobs} install DESTDIR="$destdir"

    # Compress and link man pages (if needed)
    if [ -d "${destdir}/$mandir" ] ; then
	(
            cd "${destdir}/$mandir"
	    find . -type f -exec lzip -9 '{}' +
	    find . -type l | while read -r file
	    do
		ln -sf "$(readlink -- "$file").lz" "${file}.lz"
		rm -- "$file"
	    done
	)
    fi

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"

    for file in $docs ; do
            cp -p $file "${destdir}${docsdir}"
	        done
}
